package org.learn.file;

import java.io.FileWriter;
import java.io.IOException;

public class FileWriter_ {
    public static void main(String[] args) {
        String filePath = "d:\\test\\news1.txt";
        //创建FileWrite对象
        FileWriter fileWriter = null;
        char[]chars = {'a','b','c'};

        try {
            fileWriter = new FileWriter(filePath);
            //
            fileWriter.write('j');
            fileWriter.write(chars);
            fileWriter.write("韩顺平教育".toString(),0,3);
            //在数组量大的情况下用循环操作
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            //
            try {
                fileWriter.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
